<template>
  <div>
    <BasicTable @register="registerTable" :rowSelection="rowSelection">
      <template #tableTitle>
        <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
        <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
      </template>
      <template #action="{ record }">
        <TableAction :actions="getActions(record)"/>
      </template>
    </BasicTable>
    <DetailModal @register="register" />
  </div>
</template>
<script lang="ts" name="PayMchNotify" setup>
import { ref, onUnmounted } from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useDrawer } from '/@/components/Drawer';
import DetailModal from './DetailModal.vue';
import { useGlobSetting } from '/@/hooks/setting';
import { columns, searchFormSchema } from './mchNotify.data';
import { getList, getExportUrl, getImportUrl} from './mchNotify.api';
import { useListPage } from '/@/hooks/system/useListPage';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
const glob = useGlobSetting();
const isScanCode = ref(false)
const timeInter = ref<any>(null)
const [register, { openDrawer: openDetail }] = useDrawer();
// 列表页面公共参数、方法
const { prefixCls, onExportXls, onImportXls, tableContext } = useListPage({
  designScope: 'PayMchNotify',
  tableProps: {
    title: '商户通知列表',
    api: getList,
    columns: columns,
    bordered: false,
    actionColumn: {
      width: 100,
      title: '操作',
      dataIndex: 'action',
      fixed: 'right',
      slots: { customRender: 'action' },
    },
    formConfig: {
      schemas: searchFormSchema,
      fieldMapToTime: [['fieldTime', ['beginDate', 'endDate'], 'YYYY-MM-DD HH:mm:ss']],
    },
  },
  exportConfig: {
    name: "商户通知",
    url: getExportUrl,
  },
  importConfig: {
    url: getImportUrl
  }
})

const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;

/**
 * 查看
 */
function handleDetail(record) {
  openDetail(true, {
    record,
    isUpdate: true,
  });
}
/**
 * 操作列定义
 * @param record
 */
function getActions(record) {
  return [
    {
      label: '查看',
      onClick: handleDetail.bind(null, record),
      // ifShow: record.sendStatus == 0
    }
  ]
}

onUnmounted (()=>{
  clearInterval(timeInter.value) //销毁
  timeInter.value = null
})

const handleQrCodeSuccess = () => {
  clearInterval(timeInter.value) 
}

</script>


<style>
.order-no {
  margin-bottom: 5px;
}
.order-no-data {
  float: left !important; 
  text-align: left;
  border: 1px;
  width: 150px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>